<?php


namespace common\components;


use OSS\OssClient;
use yiier\AliyunOSS\OSS;
use yii\helpers\ArrayHelper;

class AliyunOss extends OSS
{
    public $option = [
        OssClient::OSS_HEADERS => [
            'Cache-Control' => 'public,max-age=2592000',
        ],
    ];

    /**
     * @param string $fileName
     * @param string $filePath
     * @param null $option
     * @return null
     * @throws \OSS\Core\OssException
     */
    public function upload($fileName, $filePath, $option = [])
    {

        $option = ArrayHelper::merge($this->option, $option);

        return $this->getClient()->uploadFile($this->bucket, $fileName, $filePath, $option);
    }

    public function signUrl($fileName)
    {
        return $this->getClient()->signUrl($this->bucket, $fileName);
    }

}